<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册</title>
    <link rel="stylesheet" href="./css/registry.css">
    <link rel="stylesheet" href="./css/commen.css">
</head>
<body>
<div class="nav">
    <span>网页聊天室</span>
</div>
<div class="login_container">
    <div class="login_dialog">
        <h3>注册</h3>
        <div class="row">
            <span>账号</span>
            <input type="text" id="userName">
        </div>
        <div class="row">
            <span>密码</span>
            <input type="text" id="password">
        </div>
        <div class="row">
            <span>确认密码</span>
            <input type="text" id="repassword">
        </div>
        <button id="login" onclick="registry()">注册</button><br>
    </div>
</div>

<script src="./js/jquery.min.js"></script>
<script>
    function registry() {
        let userName = document.querySelector('#userName');
        let password = document.querySelector('#password');
        let repassword = document.querySelector('#repassword');
        $.ajax({
            method: 'post',
            url: '/user/registry',
            data: {
                userName: userName.value,
                password: password.value,
                repassword: repassword.value
            },
            success: function(result) {
                console.log(result)
                if (result != null && result.data == true) {
                    alert('注册成功');
                    location.href = 'login.html'
                }else {
                    alert(result.message);
                }
            }
        })
    }
</script>
</body>
</html>